# coding=UTF-8
import time
import datetime
from datetime import datetime
import glob
################################################################################
# xml element variable define
def _init():
    glob._init()
    # xml element define
    global cmd_info_table
    cmd_info_table = [
        {'commandSource'    : '1'}, 
        {'sourceSystem'     : '4'}, 
        {'version'          : '1.0'}, 
        {'commandID'        : glob.command_id},
        {'operationType'    : '0'},         #0-增加; 1-删除
        {'level'            : '1'},         #1-高; 2-中; 3-低
        {'owner'            : 'owner123'},
        {'createTime'       : glob.now_time_str},
        {'effectTime'       : glob.beg_time_str},
        {'expiredTime'      : glob.end_time_str},
        ]
    
    global cmd_object_table
    cmd_object_table = [
        {'effectSystem'     : '4'}, 
        {'effectOperator'   : '02'}, 
        {'effectVendor'     : 'vendor123'},
        {'effectPovince'    : '0'},
        {'effectHouse'      : '1'},
        ]

    global cmd_result_table
    cmd_result_table = [
        {'handleType'       : '1'}, 
        {'reportType'       : '1'}, 
        {'reportCycle'      : '1'},
        ]

    # cmd_type_table(ignore)

    # 0101
    global jmr_evil_resource_rule_table
    jmr_evil_resource_rule_table = [
        [1, 'ruleID' ,          '1202030000000001'], 
        [1, 'eventType',        '020100'], 
        [1, 'ruleDescription',  'JMR资源恶意示例'], 
        [1, 'startTime',        glob.now_time_str], 
        [1, 'endTime',          glob.end_time_str], 
        [0, 'url',              'http://www.baidu.com'], 
        [0, 'urlPositive',      '0'], 
        [0, 'domain',           'www.baidu.com'], 
        [0, 'domianPositive',   '0'], 
        [0, 'srcIp',            '1.1.1.1'], 
        [0, 'srcIpPositive',    '0'], 
        [0, 'destIp',           '2.1.1.1'], 
        [0, 'destIpPositive',   '0'], 
        [0, 'srcPort',          '10000'], 
        [0, 'srcPortPositive',  '0'], 
        [0, 'destPort',         '20000'], 
        [0, 'destPortPositive', '0'], 
        [0, 'protocolType',     '1'],   #1-TCP; 2-UDP
        [0, 'protocolTypePositive','0'], 
        [0, 'applicationProtocol','1'], 
        ]

    # 0102
    global jmr_evil_payload_rule_table
    jmr_evil_payload_rule_table = [
        [1, 'ruleType',         '0'],  #0-snort规则; 1-mtx规则
        [1, 'ruleID' ,          '1201160000000001'], 
        [1, 'eventType' ,       '011600'], 
        [1, 'ruleDescription',  'JMR恶意报文规则描述示例'], 
        [1, 'startTime',        glob.now_time_str], 
        [1, 'endTime',          glob.end_time_str], 
        [0, 'snortRule',
        'YWxlcnQgdGNwIGFueSBhbnkgLT4gMTExLjguMTQzLjMgYW55IChtc2c6IlBhcnQgLSBwYWNrZXQgbW9uaXRvcmluZyBpbnN0cnVjdGlvbiI7IHNpZDoxMjAxMTYwMDMwNTIyMDAyOyByZXY6MTsp'], 
        [0, 'mtxRule',
        'MTIwMTAxMDAxMDAwMDAwMwlQYWNrZXRNb25pdG9yaW5nSW5zdHJ1Y3Rpb24JaXAJcGFja2V0CWlwLmRzdD09MjExLjE1Ny4xMzQuMjIxCWV2ZW50KGlwLmRzdCkJMAkxCTIxCWFsZXJ0CTAJMA=='], 
        [1, 'eventDirection',   '1'], 
        [1, 'isPcap',           '1'], 
    ]

    # 0103
    global jmr_evil_file_rule_table
    jmr_evil_file_rule_table = [
        [1, 'ruleID' ,          '1203070030505294'], 
        [1, 'eventType' ,       '030700'], 
        [1, 'ruleDescription',  'AvosLocker家族-移动-恶意文件MD5'], 
        [1, 'startTime',        glob.now_time_str], 
        [1, 'endTime',          glob.end_time_str], 
        [0, 'srcIp',            '1.1.1.1'], 
        [0, 'destIp',           '2.1.1.1'], 
        [0, 'url',              'http://www.baidu.com'], 
        [0, 'domain',           '1'], 
        [0, 'malwareMd5List',
        'a1b5dc4fd2cd2b54498faf42fe9b5e50,a1b5dc4fd2cd2b54498faf42fe9b5e50,f3f1e498e191c9cfa770f743029f38ea,a1b5dc4fd2cd2b54498faf42fe9b5e50'], 
        [0, 'yaraDescription',
        'cnVsZSBkbGxfaW5qZWN0aW9uX2hvb2sgOiBzdXNwaWNpb3VzIGZlYXR1cmUgZGxsIGluamVjdGlvbiB3aW5kb3dzCnsKbWV0YToKICAgICAgICBkZXNjcmlwdGlvbiA9ICJJbmplY3Rpb24gdXNpbmcgVXNlcjMyLmRsbDpWaXJ0dWFsQWxsb2NFeCIKY29uZGl0aW9uOgogICAgICAgIHVpbnQxNigwKSA9PSAweDVhNGQgYW5kCiAgICAgICAgKAogICAgICAgICAgICAgICAgcGUuaW1wb3J0cygidXNlcjMyLmRsbCIsIlNldFdpbmRvd3NIb29rRXhBIikgb3IKICAgICAgICAgICAgICAgIHBlLmltcG9ydHMoInVzZXIzMi5kbGwiLCJTZXRXaW5kb3dzSG9va0V4VyIpCiAgICAgICAgKQp9Cg=='], 
        [1, 'isUploadFile',     '1'], 
    ]

    # 0201: jmr_dispose
    global jmr_dispose_rule_table
    jmr_dispose_rule_table = [
        [1, 'ruleType',         '5'], 
        [1, 'ruleID',           '1202010040000091'], 
        [1, 'eventType' ,       '020100'], 
        [1, 'ruleDescription',  '部侧-处置指令下发'], 
        [1, 'startTime',        glob.now_time_str], 
        [1, 'endTime',          glob.end_time_str], 
        [1, 'valueStart',
        'aHR0cDovLzIxMS4xNTcuMTM0LjIyMToxMjU4MC9qbXIvb3JkZXIvMEE2RTYxQzRGNjU2MkQ2RjBCM0Y1RTBFNUI3OTA5MUY='], 
        [0, 'valueEnd',         ''], 
        [1, 'reason',           '恶意URL'], 
        [1, 'type',             '0'], 
        [0, 'redurl',           ''], 
        [1, 'log',              '1'], 
    ]
